from django.db import models
from django.contrib.auth.models import User

class Assignments(models.Model):
    name = models.CharField(max_length=250)
    description = models.TextField()
    def __unicode__(self):
        return self.name

class Submissions(models.Model):
    assignment = models.ForeignKey(Assignments)
    student = models.ForeignKey(User)
    file = models.FileField(upload_to="submissions")
    timeSubmitted = models.DateTimeField(auto_now_add=True)
    selfGrade = models.IntegerField()
    finalGrade = models.IntegerField()

class Grades(models.Model):
    submission = models.ForeignKey(Submissions)
    user = models.ForeignKey(User)
    grade = models.IntegerField()
    comments = models.TextField()

class GradeWeight(models.Model):
    assignment = models.ForeignKey(Assignments)
    studentWeight = models.IntegerField()
    professorWeight = models.IntegerField()
    taWeight = models.IntegerField()
    peerWeight = models.IntegerField()

class UserProfile(models.Model):
    TYPES = (
            ("Student", "Student"),
            ("TA", "TA"),
            ("Professor", "Professor")
            )
    user = models.OneToOneField(User)
    type = models.CharField(choices=TYPES, max_length=15)
    ranking = models.IntegerField()
